#!/bin/bash
snapshot=""
artifactId=$1
if [ "$#" == "2" ]; then
   snapshot=$2
fi
echo $snapshot >>/tmp/borrame
echo $* >>/tmp/borrame
pushd . >/dev/null
cd ${artifactId}
if [ "$snapshot" != "" ]; then
   ls ${artifactId}*.*|grep ${snapshot}|sort |tail -1|sed s:"${artifactId}-":"":g|cut -d'-' -f1,2
else 
   ls ${artifactId}*.*|grep -v "SNAPSHOT"|sort |tail -1|sed s:"${artifactId}-":"":g|cut -d'-' -f1
fi
popd >/dev/null
